package src.dp.sequence;

public class no1668 {//最大重复子字符串

    /**
     * dp[i][j]含义：sequence中长度为[0, i-1]的子串 与 word中长度为[0, j-1]的子串中，word重复次数为dp[i][j]
     * 递推公式：
     * 初始化数组：
     * 遍历顺序：
     */

    //TODO:没做完
    public int maxRepeating(String sequence, String word) {
        int len1 = sequence.length();
        int len2 = word.length();
        int count = 0;
        int i=0,j=0;
        while(i<len1 && j<len2){
            if(sequence.charAt(i)==word.charAt(j)){
                if(j==len2-1){
                    count++;
                    j=0;
                }
                i++;
                j++;
            }else {
                i++;
            }
        }

        return count;

    }


    //用String类库函数
    public int maxRepeating2(String sequence, String word) {
        String s = word;
        int count = 0;
        while (sequence.contains(s)) {
            count++;
            s += word;
        }
        return count;
    }


}
